package com.zx.demo.controller;



import com.zx.demo.service.IDemoService;
import com.zx.mvcframework.annotations.MyAutowired;
import com.zx.mvcframework.annotations.MyController;
import com.zx.mvcframework.annotations.MyRequestMapping;
import com.zx.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@MyController
@MyRequestMapping("/demo")
public class DemoController {


    @MyAutowired
    private IDemoService demoService;

    //公开的资源
    @MyRequestMapping("/get")
    public void get(HttpServletRequest request, HttpServletResponse response, String username) throws IOException {
        PrintWriter writer = response.getWriter();
        writer.println("public");
    }

    /**
     * URL: /demo/query?name=lisi
     * @param request
     * @param response
     * @param name
     * @return
     */
    @MyRequestMapping("/query")
    public void query(HttpServletRequest request, HttpServletResponse response,String name) throws IOException {
        PrintWriter writer = response.getWriter();
        writer.println(demoService.get(name));
    }
}
